package org.nanotek.mq.send;

import org.nanotek.cms.domain.message.BodyMessageContainer;
import org.nanotek.mq.MessageBuilder;
import org.nanotek.mq.MessageException;
import org.nanotek.mq.SenderService;
import org.nanotek.util.Base;
import org.springframework.amqp.core.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class MetaIndexerSenderService implements SenderService{

	@Autowired
	private Sender<BodyMessageContainer,Message> messageSenderService;

	private MessageBuilder<?,?,?> messageBuilder;

	public MetaIndexerSenderService() {
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
	}

	public void sendMessage(BodyMessageContainer messageContainer)
	{
		try {
			messageSenderService.send(messageContainer);
		}catch(Exception ex)
		{
			throw new MessageException(ex);
		}
	}

	public Sender<?,?> getMessageSenderService() {
		return messageSenderService;
	}

	@SuppressWarnings("unchecked")
	public void setMessageSenderService(Sender<?,?> messageSenderService) {
		this.messageSenderService = (Sender<BodyMessageContainer,Message>) messageSenderService;
	}

	public MessageBuilder<?,?,?> getMessageBuilder() {
		return messageBuilder;
	}

	public void setMessageBuilder(MessageBuilder<?,?,?> messageBuilder) {
		this.messageBuilder = messageBuilder;
	}
}
